/*
 * Copyright (C) 2012 Rothens
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package rpg.entities;

import rpg.Location;
import rpg.Maps.Map;
import rpg.gfx.Bitmap;
import rpg.gfx.Screen.Renderable;

/**
 * rothens.tarhely.biz
 * @author Rothens
 */
public abstract class Entity {
	
	Location loc;
	Map map;
	public int xRenderOffset = -10;
	public int yRenderOffset = -10;
	
	public abstract boolean isPassable();
	public abstract boolean tick();
	
	public Entity(){
		
	}
	
	public Entity(Location loc){
		this.loc = loc;
	}
	
	public abstract Bitmap getDrawGraphics();
	
	public void setLocation(Location loc){
		this.loc = loc;
	}
	
	public Location getLocation(){
		return loc;
	}
	
	public boolean isInView(Renderable r){
		int diff = 32;
		
		if(r.topLeft.getX() - diff < loc.getX() && r.bottomRight.getX() + diff > loc.getX()
			&& r.topLeft.getY() - diff < loc.getY() && r.bottomRight.getY() + diff > loc.getY()){
			xRenderOffset = loc.getX() - r.topLeft.getX();
			yRenderOffset = loc.getY() - r.topLeft.getY();
			return true;
		}
		return false;
	}
	
}
